package com.lwj.springbootvue.controllerAdvice;

import com.lwj.springbootvue.exception.ServiceException;
import com.lwj.springbootvue.response.Result;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.context.request.WebRequest;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(ServiceException.class)
    public Result handleServiceException(ServiceException ex) {
        // 构造错误信息对象或使用通用的错误信息结构
        return Result.error(ex.getMessage());
    }

    // 其他异常处理方法
}

